<?php

class Application_Form_PrixProduit_BestSellersForm extends Zend_Form {

	public function init() {
		$session = new Zend_Session_Namespace("codebar");
		$this->setName('bestsellers');
		$g = $session->user->getGroupeActif();
		$u = $g->getProduits();
		$old_liste = $g->getListeBS();

		$choice_enable = new Zend_Form_Element_Checkbox('auto');
		$choice_enable->setLabel('Gérer automatiquement les best sellers')
		->setAttrib('onclick','Disabled(\'BS1\');Disabled(\'BS2\');Disabled(\'BS3\');')
		->setValue($g->getBSAuto())
		->setDecorators(array('ViewHelper','FormErrors','Label','Errors'));


		$select = new Zend_Form_Element_Select('BS1');
		foreach($u as $h)
		{
			$select->addMultiOption($h->getIdProduit(),$h->getName());
		}
		$select->setLabel('Best Seller 1 :');
		$select->setValue($old_liste[0]);
		$select->setAttrib('id','BS1')->setAttrib('size',7)->setDecorators(array('Errors','FormErrors','ViewHelper','Label'));

		$select1 = new Zend_Form_Element_Select('BS2');
		foreach($u as $h)
		{
			$select1->addMultiOption($h->getIdProduit(),$h->getName());
		}
		$select1->setLabel('Best Seller 2 :');
		$select1->setValue($old_liste[1]);
		$select1->setAttrib('id','BS2')->setAttrib('size',7)->setDecorators(array('Errors','FormErrors','ViewHelper','Label'));

		$select2 = new Zend_Form_Element_Select('BS3');
		foreach($u as $h)
		{
			$select2->addMultiOption($h->getIdProduit(),$h->getName());
		}
		$select2->setLabel('Best Seller 3 :');
		$select2->setValue($old_liste[2]);
		$select2->setAttrib('id','BS3')->setAttrib('size',7)->setDecorators(array('Errors','FormErrors','ViewHelper','Label'));

		$cancel = new Zend_Form_Element_Reset('cancel');
		$cancel->setAttrib('id','send_button')
		->setLabel('Annuler')
		->setAttrib('class','button')
		->setDecorators(array('ViewHelper','FormErrors','Errors'));

		$send = new Zend_Form_Element_Submit('send');
		$send->setAttrib('id','send_button')
		->setLabel('Enregistrer')
		->setAttrib('class','button')
		->setDecorators(array('ViewHelper','FormErrors','Errors'));

		$this->addElements(array($choice_enable,$select,$select1,$select2,$send,$cancel));
	}
}